/*
 *  Copyright (C) 2010 Glauco
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.common;

import org.balisunrise.common.listeners.TransactionModeListener;
import java.lang.reflect.Method;
import org.balisunrise.common.listeners.TransactionActionsListener;

/**
 * @author Glauco
 * @version 1.0
 */
public interface TransactionActions<T extends Transaction,
        B extends VisualAction, V> extends VisualEntity<V> {

    /**
     * Recebe a Transaction a qual é seu TransactionActions.
     *
     * @param transaction
     */
    public void setTransaction(T transaction);

    /**
     * Atribui o método para criação de novas instâncias da entidade.
     * @param createMethod Method.
     */
    public void setCreateMethod(Method createMethod);

    /**
     * Altera o Modo para busca.
     */
    public void performSearch();

    /**
     * Altera o Modo para novo.
     */
    public void performNew();

    /**
     * Altera o modo para editando.
     */
    public void performEdit();

    /**
     * Altera o modo para exclusão.
     */
    public void performDelete();

    /**
     * Executa uma ação.
     */
    public void performAction(int index);

    /**
     * Adiciona uma Ação.
     *
     * @param action
     */
    public void addAction(B action);

    /**
     * Adiciona uma Ação no indece especifico.
     *
     * @param action
     * @param index
     */
    public void addAction(B action, int index);

    /**
     * Retorna um array das Ações, Incluindo as ações de Search, New, Edit e
     * Delete.
     */
    public B[] getActions();

    /**
     * Adiciona um listener que deverá ser disparado quando houver uma alteração no
     * Modo da Transaction
     *
     * @param listener
     */
    public void addModeChangedListener(TransactionModeListener listener);

    /**
     * Remove um listener.
     *
     * @param index
     */
    public boolean removeModeChangedListener(TransactionModeListener listener);

    /**
     * Retorna um array com os listeners do objeto.
     */
    public TransactionModeListener[] getModeChangedListeners();

    /**
     * Adiciona um listener.
     *
     * @param listener the listener to be added.
     */
    public void addTransactionActionsListener(
            TransactionActionsListener listener);

    /**
     * Remove um listener.
     *
     * @param listener the listener to be removed.
     * @return true if the listener was removed, false if the listener was not
     * included.
     */
    public boolean removeTransactionActionsListener(
            TransactionActionsListener listener);

    /**
     * Retorna um array com os listeners.
     *
     * @return
     */
    public TransactionActionsListener[] getTransactionActionsListeners();
}